<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>升级VIP - FRM</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style" />
	<meta content="telephone=no" name="format-detection" />
     <link href="../Ryancss/upgrade_vip.css" rel="stylesheet" type="text/css"/>


		<style type="text/css">

	   .display-block{
	   display :block ;
	   }

	   .display-none{
	   display :none ;
	   }




	  .aui-flex-border {
    border-radius: 50px;
    padding: 0;
    background: #f4f3f3;

}

	.aui-flex {
    display: -webkit-box;
    display: -webkit-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;

	margin: 0 auto;
    width: 90%;

}


.aui-flex-box {
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: #333;
}


.aui-flex-box input {
    border: none;
    background: none;
    font-size: 0.85rem;
    padding-left: 1.4rem;
    width: 100%;
}


.aui-button-once button {
    background-image: linear-gradient(to bottom,#a442ce,#b84dc7);
    background-color: #a241cf;
    box-shadow: 0 0 19px #dd7fe6;
    color: #fff;
    font-size: 0.9rem;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    border: none;
    margin-top: 8px;
    margin-bottom: 8px;
    margin-right: 10px;
}





		</style>


</head>
<body>

<section class="aui-flexView">

	<section class="aui-scrollView">
		<div class="aui-member-head">
			<div class="aui-flex">
				<div class="aui-flex-user" id="headimgurl">
					<img src="">
				</div>
				<div class="aui-flex-box aui-flex-box-top">
					<h2 id="username"> <em>升级会员</em></h2>
				</div>
			</div>










						<div class="aui-flex aui-flex-border">
                            <div class="aui-flex-box">
                                <input  id="kami"  type="text" placeholder="请输入激活码" >
                            </div>
                            <div class="aui-button-once" onclick="loginOff()">
                                <button>使用</button>
                            </div>
                        </div>







			<div class="aui-member-box">

				<div class="aui-palace">



				<h1>
					<img src="">
				</h1>


					<a href="#" class="aui-palace-grid">
						<div class="aui-palace-grid-icon">
							<img src="">
						</div>
						<div class="aui-palace-grid-text">
							<h2>全网VIP影视</h2>
							<p>任性看</p>
						</div>
					</a>
					<a href="#" class="aui-palace-grid">
						<div class="aui-palace-grid-icon">
							<img src="">
						</div>
						<div class="aui-palace-grid-text">
							<h2>海量推荐影视</h2>
							<p>抢先看</p>
						</div>
					</a>
					<a href="#" class="aui-palace-grid">
						<div class="aui-palace-grid-icon">
							<img src="">
						</div>
						<div class="aui-palace-grid-text">
							<h2>全球直播</h2>
							<p>随意看</p>
						</div>
					</a>


					<h1>
					<img src="">
				</h1>

					<a href="#" class="aui-palace-grid">
						<div class="aui-palace-grid-icon">
							<img src="">
						</div>
						<div class="aui-palace-grid-text">
							<h2>广告管理</h2>
						</div>
					</a>
					<a href="#" class="aui-palace-grid">
						<div class="aui-palace-grid-icon">
							<img src="">
						</div>
						<div class="aui-palace-grid-text">
							<h2 id="agency_interest_two"> <!--代理收益2--></h2>
						</div>
					</a>
					<a href="#" class="aui-palace-grid">
						<div class="aui-palace-grid-icon">
							<img src="">
						</div>
						<div class="aui-palace-grid-text">
							<h2>管理后台</h2>
						</div>
					</a>
				</div>

			</div>
		</div>




		<div class="aui-flex-b">
			<div class="aui-flex-box">
				<h2> <i class="icon icon-member"></i> 升级超级会员</h2>
			</div>
		</div>
		<div class="aui-flex-member-list">
			<ul class="aui-cho-box display-none"  id="display-block" >



			</ul>
		</div>








		<div class="display-none" id="display-block-daili_faka">
		<div class="aui-member-get">
			<button  onclick="daili_faka()"><span><!--代理模式升级会员-->购买激活码</button>
		</div>
		</div>


		<div class="aui-member-get" >
			<button   onclick="addorder(-1)"><span id="daili_price"><!--代理价格--></span> 升级代理</button>
		</div>



	<!--
		<div class="aui-flex">
			<div class="aui-flex-box">
				<h3>高级权益可为您每年多节省 <em>≈2700元</em></h3>
			</div>
		</div>

		<div class="aui-list-box">
			<a href="#" class="aui-flex">
				<div class="aui-flex-box">
					<h5>无劵返利订单100笔/年</h5>
				</div>
				<div class="aui-flex-text">
					<p>返利加倍多返利 <em>900元</em></p>
				</div>
			</a>
			<a href="#" class="aui-flex">
				<div class="aui-flex-box">
					<h5>无劵返利订单100笔/年</h5>
				</div>
				<div class="aui-flex-text">
					<p>多奖励约 <em>1200元</em></p>
				</div>
			</a>
			<a href="#" class="aui-flex" style="border-bottom:none">
				<div class="aui-flex-box">
					<h5>无劵返利订单100笔/年</h5>
				</div>
				<div class="aui-flex-text">
					<p>多赚约 <em>600元</em></p>
				</div>
			</a>
		</div>
-->
	</section>
</section>
</body>

<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
    var user_id = localStorage.getItem('user_id');
    var api_url = localStorage.getItem('api_url');
    apiready = function(){
      api.parseTapmode();



/*
		 api.showProgress({
			  title: '加载中',
			  modal: false
		 });
	*/


													if (localStorage.getItem('userlogo_Cache') !== '' && localStorage.getItem('userlogo_Cache') !== null){			//  如果头像不为空

													headimgurl.innerHTML = '<img src="data:image/png;base64,'+ localStorage.getItem('userlogo_Cache')+'">' ;

												}else {
													if (localStorage.getItem('headimgurl') !== ''){			//  如果头像不为空

															headimgurl.innerHTML = '<img src="'+ localStorage.getItem('headimgurl')+'">' ;
													}
												}






							if (localStorage.getItem('nick_name') !== ''){

									/* 昵 称 */		username.innerHTML = localStorage.getItem('nick_name')+'<em>升级会员</em>';


								}else{

									/*用 户 名*/	username.innerHTML = localStorage.getItem('user_name')+'<em>升级会员</em>';

							}






      GetData();   //获取数据





      var clipBoard = api.require('clipBoard');
      clipBoard.get(function(ret, err) {
          if (ret) {

            if (ret.value.length == localStorage.getItem('kami_length')) {
              var kami = $api.byId('kami');
              kami.value = ret.value;


            /*  api.toast({
                  msg: '智能识别\n\n'+ret.value+'\n\n已为您粘贴',
                  duration: 8000,
                  location: 'middle'
              });
			  */



												var dialogBox = api.require('dialogBox');
												dialogBox.alert({
													texts: {
														title: '智能识别',
														content: '激活码：'+ret.value+'\n\n是否使用？',
														leftBtnTitle: '取消',
														rightBtnTitle: '确认并使用'
													},
													styles: {
														bg: '#fff',
														w: 300,
														corner:10,
														title: {
															marginT: 20,
															icon: 'widget://Ryanimg/frame0/rrrr.png',
															iconSize: 20,
															titleSize: 14,
															titleColor: '#999'
														},
														content: {
															marginT: 20,       //（可选项）数字类型；内容文本顶端与标题栏底端的距离，如果标题栏不存在，则是到窗口顶端的距离；默认：20
															marginB: 20,       //（可选项）数字类型；内容文本底端与 left/right 顶端的距离，如果 left/right 都不存在，则是到对话框底端的距离；默认：20
															color: '#999',
															size: 14
														},
														left: {
															marginB: 30,
															marginL: 30,
															w: 100,
															h: 35,
															corner: 2,
															bg: '#eeeeee',
															color: '#999',  //（可选项）字符串类型；右边按钮标题字体颜色，支持rgb、rgba、#；默认：'#007FFF'
															size: 12
														},
														right: {
															marginB: 30,
															marginL: 40,
															w: 100,
															h: 35,
															corner: 2,
															bg: '#ff1679',
															color: '#fff',  //（可选项）字符串类型；右边按钮标题字体颜色，支持rgb、rgba、#；默认：'#007FFF'
															size: 12
														}



													}
												}, function(ret) {

																				if (ret.eventType == 'left') {

																					//关闭弹窗
																					var dialogBox = api.require('dialogBox');
																					dialogBox.close({
																						dialogName: 'alert'
																					});



																						//清空剪贴板
																					var clipBoard = api.require('clipBoard');
																					clipBoard.set({
																						value: '聚眾影視'
																					});




																				} else if(ret.eventType == 'right') {

																							loginOff();  //使用激活码


																					//关闭弹窗
																					var dialogBox = api.require('dialogBox');
																						dialogBox.close({
																						dialogName: 'alert'
																					});




																						//清空剪贴板
																					var clipBoard = api.require('clipBoard');
																					clipBoard.set({
																						value: '聚眾影視'
																					});




																				}

																			});

																		}
																	  }
																  });



									// 网络状态
								api.addEventListener({
									name:'offline'
								}, function(ret, err){

									api.toast({
									msg : '网络连接异常',
									duration : 5000,
									location : 'middle'
									});



								});

								api.addEventListener({
									name:'online'
								}, function(ret, err){

									  api.toast({
									  msg : '已经连接网络',
									  duration : 2000,
									  location : 'middle'
									  });


							   	GetData();   //获取数据


								});


 gettaocan();//



    }
  //  初始化结束




function gettaocan(){



	api.ajax({
			url: api_url+'/login/login/gettaocan.html',
			method: 'get',
			data: {
					values: {
		         //	key: 'qq166098756',   //安全码
							uid: localStorage.getItem('user_id')
					}
			}
	},function(ret, err){



s='';
var html=$api.byId("display-block");

for(i=0;i<ret.data.length;i++){
	s+='<li class="aui-flex on" onclick="addorder('+ret['data'][i]['id']+')" data="'+ret['data'][i]['id']+'"><div class="aui-flex-time"><h1>'+ret['data'][i]['name']
	+'</h1></div><div class="aui-flex-box"><h2>原价 <em>'+ret['data'][i]['price']+'</em></h2></div><div class="aui-flex-tag"><h2><em>限时特惠</em> ￥'
	+ret['data'][i]['money']+'</h2></div></li>';
}
html.innerHTML=s;
	});




}




function addorder(id){

  if(id>=0){
		 var title="确定要购买激活码吗?";
	}else{
		 var title="确定要升级代理吗? ";
	}
	api.confirm({
	    title: title,
	    msg: '',
	    buttons:[ '确认购买', '取消购买']
	},function(ret,err){
	    if(ret.buttonIndex == 1){
	    //    api.alert({msg: '点击了确定'});
			api.showProgress({
				 title: '提交订单中',
				 modal: false
			});


		//增加订单





		api.ajax({
				url: api_url+'/login/login/addorder.html',
				method: 'post',
				data: {
						values: {
								id: id,   //安全码
								uid: localStorage.getItem('user_id')
						}
				}
		},function(ret, err){


		if(ret){

			if(ret.code!=1){

				api.hideProgress();   //关闭加载提示
					api.toast({
							msg: ret.msg,
							duration: 5000,
						location : 'middle'
						});
			}else{
				    api.title="购买激活码";
	          api.hideProgress();   //关闭加载提示
						var order=ret.order;
						location.href=api_url+"/login/login/sendpay.html?order="+order+"&userid="+localStorage.getItem("user_id");
			}


		}else{
		api.hideProgress();   //关闭加载提示
			api.toast({
					msg: '提交订单失败',
					duration: 5000,
				location : 'middle'
				});
		}

		})

	}else{

		api.toast({
				msg: '取消成功',
				duration: 2000,
			 location : 'middle'
			});

	}
	});









}





    function GetData(){



/*
		 api.showProgress({
			  title: '加载中',
			  modal: false
		 });
	*/


      api.ajax({
          url: api_url+'/login/login/upgrade_vip.html',
          method: 'get',
          data: {
              values: {
				  key: 'qq166098756',   //安全码
                  uid: localStorage.getItem('user_id')
              }
          }
      },function(ret, err){
          if (ret) {
			if (ret.code == 1) {


          // 	localStorage.setItem('url',ret.msg['url']+'&id='+user_id);

        //去掉狗粮养的支付接口         localStorage.setItem('url1',api_url+'/'+ret.msg['pay']+'/?name=体验卡&fee='+ret.msg['vip1']+'&uid='+user_id);
        //去掉狗粮养的支付接口         localStorage.setItem('url2',api_url+'/'+ret.msg['pay']+'/?name=月卡&fee='+ret.msg['vip2']+'&uid='+user_id);
        //去掉狗粮养的支付接口         localStorage.setItem('url3',api_url+'/'+ret.msg['pay']+'/?name=季卡&fee='+ret.msg['vip3']+'&uid='+user_id);
        //去掉狗粮养的支付接口         localStorage.setItem('url4',api_url+'/'+ret.msg['pay']+'/?name=半年卡&fee='+ret.msg['vip4']+'&uid='+user_id);
        //去掉狗粮养的支付接口         localStorage.setItem('url5',api_url+'/'+ret.msg['pay']+'/?name=年卡&fee='+ret.msg['vip5']+'&uid='+user_id);
        //去掉狗粮养的支付接口         localStorage.setItem('url6',api_url+'/'+ret.msg['pay']+'/?name=永久卡&fee='+ret.msg['vip6']+'&uid='+user_id);

          /*    localStorage.setItem('url2',ret.msg['url2']+'&id='+user_id);
                localStorage.setItem('url3',ret.msg['url3']+'&id='+user_id);
                localStorage.setItem('url4',ret.msg['url4']+'&id='+user_id);
                localStorage.setItem('url5',ret.msg['url5']+'&id='+user_id);
                localStorage.setItem('url6',ret.msg['url6']+'&id='+user_id);
				*/


         //去掉狗粮养的支付接口     localStorage.setItem('pay',ret.msg['pay']);
         //去掉狗粮养的支付接口     localStorage.setItem('d_pay',ret.msg['d_pay']);

				//价格
                localStorage.setItem('vip1',ret.msg['vip1']);
                localStorage.setItem('vip2',ret.msg['vip2']);
                localStorage.setItem('vip3',ret.msg['vip3']);
                localStorage.setItem('vip4',ret.msg['vip4']);
                localStorage.setItem('vip5',ret.msg['vip5']);
                localStorage.setItem('vip6',ret.msg['vip6']);


				//发卡
                localStorage.setItem('faka_vip1',ret.msg['faka_vip1']);
                localStorage.setItem('faka_vip2',ret.msg['faka_vip2']);
                localStorage.setItem('faka_vip3',ret.msg['faka_vip3']);
                localStorage.setItem('faka_vip4',ret.msg['faka_vip4']);
                localStorage.setItem('faka_vip5',ret.msg['faka_vip5']);
                localStorage.setItem('faka_vip6',ret.msg['faka_vip6']);

                localStorage.setItem('daili_faka',ret.msg['daili_faka']);         //代理设置发卡平台

                localStorage.setItem('daili_price',ret.msg['daili_price']);		//代理升级价格
                localStorage.setItem('kami_length',ret.msg['kami_length']);    //卡密长度
           //     localStorage.setItem('headimgurl',ret.msg['headimgurl']);    //用户头像
            //    localStorage.setItem('username',ret.msg['username']);    //用户名
                localStorage.setItem('app_working_mode',ret.msg['app_working_mode']);    //工作模式
                localStorage.setItem('parentid',ret.msg['parentid']);    //父ID







                //var vip2 = $api.byId('vip2');
              //  vip2.innerHTML = '<em>限时特惠</em>  ￥'+localStorage.getItem('vip2');
              //  vip2_y.innerHTML = localStorage.getItem('vip2')*1.5;

                // var vip3 = $api.byId('vip3');
                // vip3.innerHTML = '<em>限时特惠</em>  ￥'+localStorage.getItem('vip3');
                // vip3_y.innerHTML = localStorage.getItem('vip3')*1.5;
								//
                // var vip4 = $api.byId('vip4');
                // vip4.innerHTML = '<em>限时特惠</em>  ￥'+localStorage.getItem('vip4');
                // vip4_y.innerHTML = localStorage.getItem('vip4')*1.5;
								//
                // var vip5 = $api.byId('vip5');
                // vip5.innerHTML = '<em>限时特惠</em>  ￥'+localStorage.getItem('vip5');
                // vip5_y.innerHTML = localStorage.getItem('vip5')*1.5;
								//
                // var vip6 = $api.byId('vip6');
                // vip6.innerHTML = '<em>限时特惠</em>  ￥'+localStorage.getItem('vip6');
                // vip6_y.innerHTML = localStorage.getItem('vip6')*1.5;
								//
                var daili_price = $api.byId('daili_price');
                daili_price.innerHTML = '￥ '+localStorage.getItem('daili_price');



				//工作模式判断
				if(localStorage.getItem('app_working_mode') =='1'){        //如果工作模式为返佣

           //     agency_interest_one.innerHTML = '团队收益';
                agency_interest_two.innerHTML = '团队收益';

								//如果是返佣模式 展示详细列表
							  var obj = document.getElementById("display-block");
							  obj.setAttribute("class", "display-block");

				}else{

           //     agency_interest_one.innerHTML = '广告管理';
                agency_interest_two.innerHTML = '低价拿卡';


									var obj = document.getElementById("display-block-daili_faka");
									obj.setAttribute("class", "display-block");

								//如果是代理模式 且父ID 为 管理员 展示详细列表
								if(localStorage.getItem('parentid') =='1'){
									var obj = document.getElementById("display-block");
									obj.setAttribute("class", "display-block");
								}


				}








            }//信息获取END

				api.hideProgress();   //关闭加载提示

          } else {

				api.hideProgress();   //关闭加载提示

				api.toast({
						msg: '数据加载异常',
						duration: 5000,
					location : 'middle'
					});


            return;
          }
      });
    }



	// 体验
    function openUrl1(){


					  var openUrl1_str = localStorage.getItem('faka_vip1') ;

					  if(openUrl1_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('faka_vip1'));

					  }else{

								go_up_kefu();  //跳转客服
					  }

    }


   //月卡
    function openUrl2(){



					  var openUrl2_str = localStorage.getItem('faka_vip2') ;

					  if(openUrl2_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('faka_vip2'));

					  }else{

								go_up_kefu();  //跳转客服
					  }


    }



	   //季卡
    function openUrl3(){


					  var openUrl3_str = localStorage.getItem('faka_vip3') ;

					  if(openUrl3_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('faka_vip3'));

					  }else{

								go_up_kefu();  //跳转客服
					  }

    }


	   //半年卡
    function openUrl4(){

					  var openUrl4_str = localStorage.getItem('faka_vip4') ;

					  if(openUrl4_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('faka_vip4'));

					  }else{

								go_up_kefu();  //跳转客服
					  }


    }


	   //年卡
    function openUrl5(){

					  var openUrl5_str = localStorage.getItem('faka_vip5') ;

					  if(openUrl5_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('faka_vip5'));

					  }else{

								go_up_kefu();  //跳转客服
					  }



    }


	   //永久
    function openUrl6(){


					  var openUrl6_str = localStorage.getItem('faka_vip6') ;

					  if(openUrl6_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('faka_vip6'));

					  }else{

								go_up_kefu();  //跳转客服
					  }


    }








	// 代理发卡
    function daili_faka(){

			if (localStorage.getItem('user_id') ==  1) {			//如果是管理员

						api.toast({
							msg: '管理员登录 终止',
							duration: 5000,
							location : 'middle'
						});

			}else {

					  var daili_faka_str = localStorage.getItem('daili_faka') ;

					  if(daili_faka_str.indexOf("http")>-1){

							toBanner(localStorage.getItem('daili_faka'));

					  }else{

								go_up_kefu();  //跳转客服
					  }


					  /*
					  if (localStorage.getItem('daili_faka') ==  '' ) {			//如果代理发卡为空


								go_up_kefu();  //跳转客服


						}else  if (localStorage.getItem('daili_faka') ==  null ) {			//如果代理发卡为空


								go_up_kefu();  //跳转客服


						}else  if (localStorage.getItem('daili_faka') ==  '无数据' ) {			//如果代理发卡为空


								go_up_kefu();  //跳转客服
						}else{

							toBanner(localStorage.getItem('daili_faka'));
						}
*/

			}
    }




	// 升级代理 跳转管理员客服
    function up_daiil(){

        api.openWin({
            name: 'upgrade_agent_win',
            url: 'widget://html/upgrade_agent_win.html'
        });

    }



	// 客服
    function go_up_kefu(){


        api.openWin({
            name: 'customer_service_win',
            url: 'widget://html/setup/customer_service_win.html'
        });

    }







      //访问地址
      function toBanner(url){
        var sys = api.systemType;
        if (sys == 'ios') {
          if (url == '') {
            keFu();
            return;
          }else {

		/*
		              api.openWin({
                name: 'h5',
                url: './h5.html',
                pageParam: {
                    url: url
                }
            });

	*/

            api.openApp({
                   iosUrl: url
           },function(ret,err){
           });



          }
        }else {
          // if (url == '') {
          //
          // }else {
          //   api.openApp({
          //       androidPkg: 'android.intent.action.VIEW',
          //       mimeType: 'text/html',
          //       uri: url
          //   }, function(ret, err) {
          //       // if (ret) {
          //       //     alert(JSON.stringify(ret));
          //       // } else {
          //       //     alert(JSON.stringify(err));
          //       // }
          //   });
          //
          // }
          if (url == '') {
            keFu();
            return;
          }else {
            api.openWin({
                name: 'h5',
                url: './h5.html',
                pageParam: {
                    url: url
                }
            });
          }

        }

        // if (url == '') {
        //
        // }else {
        //   api.openWin({
        //       name: 'h5',
        //       url: './h5.html',
        //       pageParam: {
        //           url: url
        //       }
        //   });
        // }
      }


    //充值点卡
    function loginOff(){
      var kami = $api.val($api.byId('kami'));
      if(kami == ''){
        api.toast({
            msg: '激活码还没输入',
            duration: 5000,
            location : 'middle'
        });
        return;
      }
      if (user_id<1) {
        alert('请先登录');
        api.openWin({
            name: 'login',
            url: './login.html',
        });
        return;
      }else {
        api.showProgress({
            title: '验证中',
            text: '请稍等',
            modal: false
        });
        api.ajax({
            url: api_url+'/login/login/activation_code.html',
            method: 'get',
            data: {
                values: {
                    uid: localStorage.getItem('user_id'),
                    dianka: kami,
					key: 'qq166098756'   //安全码
                }
            }
        },function(ret, err){
            if (ret) {
                if (ret.code == 0) {
                  api.hideProgress();

		        api.toast({
					msg: ret.msg,
					duration: 5000,
					location : 'middle'
				});



                  return;
                }else if(ret.code == 8){

				api.hideProgress();


		        api.toast({
					msg: ret.msg,
					duration: 5000,
					location : 'middle'
				});


                  localStorage.setItem('user_time',ret.lasttime);
				   setTimeout("delayed()",1000);  //延迟执行 关闭




				}else if (ret.code == 1) {
                  api.hideProgress();


		        api.toast({
					msg: ret.msg,
					duration: 5000,
					location : 'middle'
				});


                  localStorage.setItem('user_time',ret.lasttime);

				   setTimeout("delayed()",1000);  //延迟执行 关闭

                }

            } else {
              api.hideProgress();

		        api.toast({
                      msg: '网络异常',
					duration: 5000,
					location : 'middle'
				});
	/*

              api.alert({
                  title: '糟糕~',
                  msg: '网络似乎有点问题',
              });
			  */

            }
        });

      }
    }








		//延时执行
	    function delayed(){

                  api.sendEvent({
                    name: 'newLoingdata',
                    extra: {
                    }
                  });

                  api.closeWin();

				}

</script>
</html>
